<#include "../common/layout.ftl"/>
<@layout>
<div width="100%" style="height: 900px;">
	<div class="dxfsqd_title">已完成订单</div>
	<div class="dxfsqd_shearch">
		<form method="post" action="/order/finishList" class="form-inline" id="form1" >
			<label><span>订单号：</span><input type="text" class="input-medium" style="height: 30px" name="id"/></label> 
			<label><span>工号：</span><input type="text" class="input-medium" style="height: 30px" name="job_number" value="${jobNumber?if_exists}"/></label> 
			<label><span>姓名：</span><input type="text" class="input-medium" style="height: 30px"  name="real_name" value="${name?if_exists}"/></label> 
			<label><span>开始时间：</span><input type="text" class="input-medium" style="height: 30px"  name="beginDate" value="${beginDate!""}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})"/></label> 
			<label><span>结束时间：</span><input type="text" class="input-medium" style="height: 30px"  name="endDate" value="${endDate!""}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})"/></label> 
			<button type="submit" class="btn "><i></i>查询</button>
			<button type="button" class="btn btn-info" onclick="javascript:history.back();">返回</button>
			<#if session.userRole == 'admin' || session.userRole == 'brandManager'>
				<label><span>导出</span><a class="dc_exc"  href="/order/finishExcel">导出Excel文件</a></label>
	    	</#if>
		</form>
</div>
<div class="dxfsqd_table">

	<table class="table table-bordered table-striped" style="word-break: keep-all;">
		<thead>
		  <tr>
			<th scope="col">单号</th>
			<!-- <th>订单来源</th> -->
			<th scope="col">订单种类</th>
			<!-- <th>客户姓名</th> -->
			<th scope="col">客户手机</th>
			<!-- <th>客户性别</th> -->
			<th scope="col">起点</th>
			<th scope="col">终点</th> 
			<th scope="col">里程</th>
			<th scope="col">金额</th>
			<th scope="col">原价</th>
			<th scope="col">费用</th>
			<th scope="col">支付方式</th>
			<th scope="col">订单类型</th>
			<th scope="col">代驾员姓名</th>
			<th scope="col">代驾员工号</th>
			<th scope="col">联系方式</th>
			<!-- <th>客户下单时间</th> -->
			<!-- <th>客服派单时间</th> 
			<th scope="col">代驾员接受时间</th>
			<th scope="col">已到达时间</th>
			<th scope="col">开始代驾时间</th>-->
			<th scope="col">时间</th>
			<!-- <th>行程查询</th> -->
			<!-- <th>使用人</th>
			<th scope="col">使用人姓名</th>
			<th scope="col">代叫</th> -->
			<th scope="col">备注</th>
			<th scope="col">员工备注</th>
			<th scope="col">操作</th>
		  </tr>
		</thead>
		<tbody>
		
		<#list page.list as order>
            <tr>

		  <td><a href="/order/orderDetailView/${order.id}">${order.id}</a></td>
		 <!--  <td>
			  <#list session.telLists as tel>
		      <#if tel.company ??>
			  	 <#if order.source==tel.company>
			  	 	${tel.companyname!""}
			  	 </#if>
			  </#if>
			  </#list>
		  </td> -->
		  <td>
		    <#if order.order_category_type ??>
				<#list session.orderTypeMapList as orderType>
	    			<#if orderType.value == order.order_category_type>
	    			  ${orderType.name}
	    			</#if>
	    		</#list>
    	    </#if>
		  </td>
			<#if order.member_id??>
				<!-- <td>
				  ${order.real_name!""}
				</td> -->
				<td>
				  ${order.cell_phone!""}
				</td>
				<!-- <td>
				  <#if order.sex??>
					  <#if order.sex == 0>
					  	<span class="label label-info">男</span>
					  <#elseif order.sex == 1>
					  	<span class="label label-warning">女</span>
					  <#else>
					  	<span class="label label-inverse">未知</span>
					  </#if>
				  </#if>
				</td> -->
		  	<#else>
				<!-- <td>
				  ${order.real_name2!""}
				</td> -->
				<td>
				  ${order.cell_phone2!""}
				</td>
				<!-- <td>
				  <#if order.sex2??>
					  <#if order.sex2 == 0>
					  	<span class="label label-info">男</span>
					  <#elseif order.sex2 == 1>
					  	<span class="label label-warning">女</span>
					  <#else>
					  	<span class="label label-inverse">未知</span>
					  </#if>
				  </#if>
				</td> -->
		  	</#if>
			<td>
				<#if order.startpoint??>
					<#if order.startpoint?length gt 10>
						${order.startpoint}
					<#else>
						${order.startpoint}
					</#if>
				 	
				<#else>
					""
				</#if>
				
			</td>
			<td>
				<#if order.endpoint??>
					<#if order.endpoint?length gt 10>
						${order.endpoint}
					<#else>
						${order.endpoint}
					</#if>
				 	
				<#else>
					""
				</#if>
				
			</td>
			<td>
			 ${order.kilometre!""}
			</td>
			<td>
			 ${order.totalmoney!""}
			</td>
			<#if order.costprice??>
				<#if order.costprice!=order.totalmoney>
					<td style="color:red">
						${order.costprice }
					</td>
				<#else>
					<td>
						${order.costprice }
					</td>
				</#if>
			<#else>
				<td>
				</td>
			</#if>
			<td>
			   <#if order.charges??>
			   	    ${order.charges?string(",##0.0#")}
			   <#else>
			   	    0.0
			   </#if>
			</td>
			<td>
			<#if order.pay_type??>
				 <#if order.pay_type == 0>
			  	<span class="label label-info">现金</span>
			  <#elseif order.pay_type == 1>
			  	<span class="label label-warning">余额支付</span>
			  <#elseif order.pay_type == 2>
			  	<span class="label label-success">VIP支付</span>
			  <#elseif order.pay_type == 3>
			  	<span class="label label-success">微信支付</span>
			  <#else>
			  	<span class="label label-inverse">其他</span>
			  </#if>
			  </#if>
			</td>
			<td>
			   <#if order.from_source ??>
			    <#if order.from_source == "WECHAT">
		  	 	公众号
		  	 	<#elseif order.from_source == "APP">
		  	 	自建
		  	 	<#elseif order.from_source == "ADMIN">
		  	 	强制派单
		  	 	<#elseif order.from_source == "CLIENT">
		  	 	客户端
		  	 	<#elseif order.from_source == "GRAB">
		  	 	员工抢单
		  	 	<#else>
					${order.from_source!" "}
		  	 	</#if>
		  	   </#if>
			</td>
			<td>
			 ${order.driver_name!" "}
			</td>
			<td>
			 ${order.job_number!" "}
			</td>
			<td>
			 ${order.driver_phone!" "}
			</td>
		    <!-- <td>
			 <#if order.create_time??> 
			 ${order.create_time?string("MM/dd HH:mm")}  
			</#if>
			</td> -->
			<!-- <td>
			  <#if order.publish_time??> 
			 ${order.publish_time?string("MM/dd HH:mm")}  
			</#if>
			</td> 
			<td>
			  <#if order.accept_time??> 
			 ${order.accept_time?string("MM/dd HH:mm")}  
			</#if>
			</td>
			<td>
			  <#if order.arrived_time??> 
			   ${order.arrived_time?string("MM/dd HH:mm")}  
			  </#if>
			</td>
			<td>
			 <#if order.driver_begin_time??> 
			   ${order.driver_begin_time?string("MM/dd HH:mm")}  
			  </#if>
			</td>-->
			<td>
			 <#if order.driver_finish_time??> 
			   ${order.driver_finish_time?string("yyyy/MM/dd HH:mm:ss") }  
			  </#if>
			</td>
			<!-- <td>
				<#if session.userRole == 'admin' || session.userRole == 'brandManager' || session.userRole == 'middleManager' || session.userRole == 'customerCenter'>
					<div class="btn-group">
						 <a class="btn btn-success" href="/order/trajectory/${order.id}" target="_blank" ><i></i> 轨 迹</a>
					</div>
				</#if>
			</td> -->
			<!-- <#if order.call_type == 2>
				<td>${order.receive_name!""}</td>
				<td>${order.receive_phone!""}</td>
				<td>是</td>
			<#else>
				<td></td>
				<td></td>
				<td>否</td>
			</#if>-->
			<td>
			 ${order.remark!" "}
			</td>
			<td>
			 ${order.driver_remark!" "}
			</td> 
			<td>
				<div style="width:150px;">
					<#if session.userRole == 'admin' || session.userRole == 'brandManager' || session.userRole == 'middleManager' || session.userRole == 'customerCenter'>
						 <a class="cf" href="/order/trajectory/${order.id}" target="_blank" > 轨 迹</a>
					</#if>
					<#if session.userRole == 'admin' || session.userRole == 'brandManager' || session.userRole == 'middleManager' || session.userRole == 'customerCenter'>
						<a class="cf" href="/order/complaint/${order.id}">投诉</a>
					</#if>
					<br/>
					<br/>
					<!-- <#if session.userRole == 'admin' || session.userRole == 'brandManager' || session.userRole == 'middleManager' || session.userRole == 'customerCenter'>
					   	<a class="btn btn-success" href="/order/cancelAccepted/${order.id}">取消</a>
					</#if> -->
					<#if session.userRole == 'admin' || session.userRole == 'brandManager' || session.userRole == 'middleManager' || session.userRole == 'customerCenter'>
					   	<a class="cf" href="/invoice/saveInvoice/${order.id}"> 开票</a>
					</#if>
					<#if session.userRole == 'admin' || session.userRole == 'brandManager' || session.userRole == 'middleManager' || session.userRole == 'customerCenter'>
                        <#if order.updatetime ?? &&order.updatetime!="">
                            <a class="cf" style="background-color: red;background-image: -webkit-linear-gradient(top, red, red)" href="javascript:void(0);" onclick="edit(${order.id})"> 修改</a>
                        <#else>
                            <a class="cf"   onclick="edit(${order.id})" href="javascript:void(0);"> 修改</a>
                        </#if>

					</#if>
					<script>
	function edit(id){
		debugger;
		var html="/order/editOrder/"+id;
		var dd="job_number=${job_number?if_exists}&real_name=${real_name?if_exists }&cell_phone=${cell_phone?if_exists }&beginDate=${beginDate?if_exists }&endDate=${endDate?if_exists }".replace(/&/g,"amp;");
		html=html+"?fromurl="+GetUrlRelativePath()+"&param="+dd;
		window.location.href=html;
	}
	
	function GetUrlRelativePath()
	{
		var url = document.location.toString();
		var arrUrl = url.split("//");

		var start = arrUrl[1].indexOf("/");
		var relUrl = arrUrl[1].substring(start);//stop省略，截取从start开始到结尾的所有字符

		if(relUrl.indexOf("?") != -1){
			relUrl = relUrl.split("?")[0];
		}
		return relUrl;
	}
	function excel() {
		  document.getElementById('form1').action= '/order/finishExcel';
		  document.getElementById('form1').submit();
	}
</script>
					<!--<a class="btn btn-inverse" href="/order/driverCancel/${order.id}"> 撤消</a>-->
					</div>
			</td>
		  </tr>
		</#list>
		</tbody>
	</table>
	<#include "../common/paginate.ftl" />
	<@paginate currentPage=page.pageNumber totalPage=page.totalPage actionUrl="/order/finishList/" urlParas="?job_number=${job_number?if_exists}&real_name=${real_name?if_exists }&cell_phone=${cell_phone?if_exists }&beginDate=${beginDate?if_exists }&endDate=${endDate?if_exists }" />
</div>
</div>
<script type="text/javascript" src="/js/wdatePicker/WdatePicker.js"></script>


</@layout>